#!/bin/bash
DOCKER_ID="$1"
DOCKER_NAME=`docker ps -a |grep -i "$DOCKER_ID" |awk '{print $1}'`
DOCKER_IPADDR=`docker ps -a |grep -i "$DOCKER_ID" |awk '{print $NF}'|awk -F"_" '{print "192.168."$(NF-1)"."$NF}'`
IPADDR=`ifconfig |grep "Bcast"|awk '{print $2}'|cut -d: -f2|grep "192.168"|head -1`

if [ -z $1 ];then
	echo -e "\033[32m---------------------------\033[0m"
	echo -e "\033[32mPlease Input You want Start $0 DOCKER_ID ,example $0 651cf1d11192\033[0m"
	exit 0
fi

docker start $DOCKER_ID
pipework br0 $DOCKER_NAME $DOCKER_IPADDR/24@$IPADDR
echo -e "\033[32mDoker Name $DOCKER_NAME Started,IPaddr:$DOCKER_IPADDR\033[0m"
